<template>
	<view class="content">
		<view class="head_bg">
			<image src="../../static/schedule_list/head-bg.png"></image>
		</view>
		<view class="list-title">
			<image src="../../static/schedule_list/title-img.png" class="title-img"></image>
			随访任务
		</view>
		<view class="patient_list">
			<scroll-view scroll-y="true" class="scroll_list">
				<view class="content_item" v-for="item in scheduleList" :key="item.sid" @tap="dealSchedule(item.sid)">
					<view class="schedule-head">
						<image src="../../static/schedule_list/schedule-head.png" class="schedule-headImg"></image>
					</view>
					<view class="schedule_info">
						<view class="schedule_title">
							<view class="title">
								您有一个患者{{item.patientName}}的随访任务
							</view>
							<view class="status">
								待办
							</view>
						</view>
						<view class="schedule-content">
							<image src="../../static/schedule_list/position.png" class="position"></image>
							<view class="schedule_address" v-if="item.place != null">
								地址：{{item.place}}
							</view>
							<view class="schedule_address" v-if="item.place == null">
								暂无地址
							</view>
							<view class="schedule_time">
								截至日期：{{item.endTime | subTime}}
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				showDialog_1: false,
				showDialog_2: false,
				page: 1,
				scheduleList: []
			};
		},
		created() {
			uni.showLoading({
				title: "获取数据中..."
			})
			this.getScheduleList();
		},
		onPullDownRefresh() {
			this.getScheduleList();
		},
		filters: {
			subTime: function(str) {
				return str.substr(0, 10)

			}
		},
		methods: {
			// 禁止穿透
			bindTouchmove() {},
			getScheduleList() {
				var json = new Object();
				this.$http.uniHttpPost(this.$api.server_visit_list, null).then(res => {
					console.log("server_visit_list: " + JSON.stringify(res));
					this.scheduleList = res.data.data;
					uni.hideLoading();
					uni.hideNavigationBarLoading();
					uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
				}).catch(err => {
					uni.hideLoading();
					console.log("err: " + JSON.stringify(err));
				})
			},
			dealSchedule(sid) {
				let info = {
					sid: sid,
					from: 'schedule'
				}
				uni.navigateTo({
					url: '../patient_list/operate?info=' + JSON.stringify(info)
				})
			},
			handleShow(type) {
				console.log("type:" + type);
				this[`showDialog_${type}`] = true;
			},
			clickCancel(type) {
				this[`showDialog_${type}`] = false;
			},
			clickConfirm(type) {
				this[`showDialog_${type}`] = false;
				uni.showToast({
					icon: 'success',
					title: '报警成功！',
					duration: 3000
				})
			},
			toOperate(sid) {
				uni.navigateTo({
					url: './operate?sid=' + sid
				});
			}
		}
	};
</script>

<style scoped>
	@import url('../../css/navigation.css');

	.content {
		font-size: 25upx;
		font-family: 'FZLTHJW';
		height: 100%;
		display: flex;
		flex-direction: column;
		background-color: #F2F2F2;
	}

	.head_bg {
		height: 416.66upx;
	}

	.head_bg image {
		width: 100%;
		height: 416.66upx;
		position: fixed;
		top: 0;
	}

	.patient_list {
		flex: 1;
		display: flex;
		flex-direction: column;
	}

	.scroll_list {
		height: 100%;
	}

	.list-title {
		font-size: 29.16upx;
		line-height: 1.2;
		color: rgb(0, 0, 0);
		padding-left: 34.72upx;
		height: 68.05upx;
		display: flex;
		align-items: center;
		background-color: #F2F2F2;
	}

	.content_item {
		display: flex;
		flex-direction: row;
		padding: 20.83upx 0;
		align-items: center;
		background-color: #FFFFFF;
		margin-top: 17.36upx;
	}

	.schedule_info {
		padding-left: 34.72upx;
		flex: 1;
		display: flex;
		flex-direction: column;
	}

	.schedule_time {
		display: flex;
		justify-content: flex-end;
		margin-right: 34.72upx;
	}

	.title-img {
		width: 5.55upx;
		height: 34.02upx;
		margin-right: 10.41upx;
	}

	.schedule-head {
		width: 93.75upx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.schedule-headImg {
		height: 55.55upx;
		width: 55.55upx;
	}

	.schedule_title {
		display: flex;
		flex-direction: row;
	}

	.schedule_title .title {
		flex: 1;
	}

	.status {
		margin-right: 20.83upx;
		border-width: 0.69upx;
		border-color: rgb(228, 228, 228);
		border-style: solid;
		background-color: rgb(247, 142, 5);
		width: 93.05upx;
		height: 36.8upx;
		border-radius: 19.09upx;
		font-size: 27.77upx;
		text-align: center;
		font-family: "FZLanTingHeiS-R-GB";
		color: rgb(255, 255, 255);
	}

	.schedule-content {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.schedule_address {
		flex: 1;
	}

	.position {
		width: 16.66upx;
		height: 19.44upx;
		margin-right: 6.94upx;
	}
</style>
